import { BaseModel } from "../BaseModel";

export class User extends BaseModel {

    constructor() {
        super();
        this.symbolName = "User";
        this.tableName = "t_user";
        this.id = '';//用户id
        this.name = '';//用户的名称
        this.mobile = '';//用户的手机号
        this.password = '';//用户的密码
        this.avatar = '';//用户的头像
        this.limitCount = -1;//用户限制的同时在线数目
        this.schoolName = '';//学校名称
        this.schoolId = '';//学校id
        this.eduLevelId = '';//学段id
        this.vipType = '';//VIP的类型;0-SVIP；1-VIP；2-不是VIP
        this.remainderDays = '';//剩余的VIP天数
        this.activeTime = '';//用户上一次活跃的时间
        this.offlineExpired = '';//离线后最大的使用次数
        this.bookId = '';//打开客户端第一次进入的书本id
        this.isGlobal = '' // 是否为全册用户
        this.lessonId = '';//课程id
        this.reverse1 = '';//是否显示新手引导：0/空 - 显示；1 - 不显示
        this.reverse2 = '';//是否为资源录屏白名单 1-是 0-不是
        this.reverse3 = '';//是否阅读积分兑换协议
    }

    dbMapper () {
        return {
            id: 'id',
            name: 'name',
            mobile: 'mobile',
            password: 'password',
            avatar: 'avatar',
            limitCount: 'limit_count',
            schoolName: 'school_name',
            schoolId: 'school_id',
            eduLevelId: 'edu_level_id',
            vipType: 'vip_type',
            remainderDays: 'remainder_days',
            activeTime: 'active_time',
            offlineExpired: 'offline_expired',
            bookId: 'book_id',
            isGlobal: 'is_global',
            lessonId: 'lesson_id',
            reverse1: 'reverse1',
            reverse2: 'reverse2',
            reverse3: 'reverse3'
        }
    }

    /**
     * 输出转换
     * @param obj
     * @returns {Book}
     */
    mappingModel (obj) {
        let user = new User();
        user.id = obj.id ? obj.id : ''
        user.name = obj.name ? obj.name : ''
        user.mobile = obj.mobile ? obj.mobile : ''
        user.password = obj.password ? obj.password : ''
        user.avatar = obj.avatar ? obj.avatar : ''
        user.limitCount = obj.limit_count ? obj.limit_count : -1
        user.schoolName = obj.school_name ? obj.school_name : ''
        user.schoolId = obj.school_id ? obj.school_id : ''
        user.eduLevelId = obj.edu_level_id ? obj.edu_level_id : ''
        user.vipType = obj.vip_type ? obj.vip_type : ''
        user.remainderDays = obj.remainder_days ? obj.remainder_days : ''
        user.activeTime = obj.active_time ? obj.active_time : ''
        user.offlineExpired = obj.offline_expired ? obj.offline_expired : ''
        user.bookId = obj.book_id ? obj.book_id : ''
        user.isGlobal = obj.is_global ? obj.is_global : ''
        user.lessonId = obj.lesson_id ? obj.lesson_id : ''
        user.reverse1 = obj.reverse1 ? obj.reverse1 : ''
        user.reverse2 = obj.reverse2 ? obj.reverse2 : ''
        user.reverse3 = obj.reverse3 ? obj.reverse3 : ''
        return user;
    }

}
